// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
       game: {
            default: null,
            type: cc.Node
        },
	   progress: {
            default: null,
            type: cc.ProgressBar
       },
    },

    // LIFE-CYCLE CALLBACKS:

     onLoad () {
		 console.log(this.progress.getComponent(cc.ProgressBar));
		 
		 this.progressBar=this.progress.getComponent(cc.ProgressBar);
		 
		 this.progressBar.progress=0.5;
		 
		 this.step=0;
	 },

    

     update (dt) {
		 if(this.game.getComponent('GameByTime').getStep()!=this.step){
			//console.log('change step');
			this.step = this.game.getComponent('GameByTime').getStep();
			
			this.progressBar.progress=this.step/3000;
		}
	 },
});
